<?php
	if(isset($_SESSION['IS_LOGGED']) && $_SESSION['IS_LOGGED'])
	{
		if(isset($_SESSION['follow_uid']) 
		&& !empty($_SESSION['follow_uid'])
		&& isset($_SESSION['follow_uname'])
		&& !empty($_SESSION['follow_uname']))
		{
			//echo $_SESSION['LOGGED_USER']->id . ' | ' . $_SESSION['follow_uid'];
			if($_SESSION['follow_type'] == 1)
			{
				$this->db->query('INSERT INTO Follows(who,whom,gen_date) values("' . $_SESSION['LOGGED_USER']->id . '","' . $_SESSION['follow_uid'] . '",now())');
			}
			else if($_SESSION['follow_type'] == 2)
			{
				$this->db->query('DELETE FROM Follows WHERE who="' . $_SESSION['LOGGED_USER']->id . '" and whom="' . $_SESSION['follow_uid'] . '"');
			}
		}
	}
	header('Location: '.SITEURL.'profile/'.$_SESSION['follow_uname']);
?>